'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 刷新战力
 * @author sundbcn@gmail.com (sun debing)
 */

var async = require('async');
var fightPowerService = require('../../../services/fightPowerService.js');
var Code = require('../../../consts/code');
var playerManager = require('../../../libs/playerManager');

module.exports = function (app) {
    return new Handler(app);
};

var Handler = function (app) {
    this.app = app;
};

/**
 * 刷新总战力和士兵战力
 * @param  {[type]} msg     [description]
 * @param  {[type]} session [description]
 * @param  {[type]} next    [description]
 * @return {[type]}     [description]
 */
Handler.prototype.refresh = function (msg, session, next) {
    var role_id = session.uid;

    var player_manager = new playerManager(role_id);
    player_manager.refreshData(function () {
        fightPowerService.updByIdMainPower(role_id, player_manager, next);
    });
};
